<?php
 require '../tools.func.php';
 require '../db.func.php';
 $id=intval($_GET['id']);
 if(empty($id)){
        header('location:cart.php');
 }
 $uid=getsession('id','shop');
 $prefix=getprefix();
 $sql="SELECT price,quantity,products FROM {$prefix}cart WHERE uid={$uid};";
 $res=queryone($sql);
 $res['products']=json_decode($res['products'],true);
 $price=intval($res['price'])-intval($res['products'][$id]['products']['price'])*intval($res['products'][$id]['quantity']);

 $quantity=intval($res['quantity'])-intval($res['products'][$id]['quantity']);
 unset($res['products'][$id]);

 $pan=addslashes(json_encode($res['products']));


$sql="UPDATE {$prefix}cart SET price='$price',quantity='$quantity',products='$pan' 

         WHERE uid='{$uid}' ";
var_dump($sql);
  execute($sql);
header('location:cart.php');
